Skip to content

fix(memory): patch ConcurrentStorage leak (WeakValueDictionary)#1353

Merged
TimothyZhang7 merged 2 commits intoaden-hive:mainfrom
Tahir-yamin:fix/concurrent-storage-file-locks-leak
Jan 27, 2026
Merged

fix(memory): patch ConcurrentStorage leak (WeakValueDictionary)#1353
TimothyZhang7 merged 2 commits intoaden-hive:mainfrom
Tahir-yamin:fix/concurrent-storage-file-locks-leak

Conversation

@Tahir-yamin
Copy link
Contributor

Description

Fixes #517 (Memory leak in concurrent storage)

This PR addresses the unbounded memory growth in ConcurrentStorage by replacing the global lock cache with a WeakValueDictionary and implementing strict LRU eviction for active run locks.

Changes

  • Replaced _global_lock logic with WeakValueDictionary to allow unused file locks to be garbage collected.
  • Implemented _lru_tracking (OrderedDict) to keep 'hot' run locks in memory while evicting cold ones.
  • Added max_locks parameter to control memory usage.
  • Removed unrelated formatting/linting changes (reduced from 73 files to 1).

Verification

  • Added tests/test_concurrent_storage_leak.py verifying:
    • Lock lifecycle and reuse
    • LRU eviction behavior
    • Weak reference garbage collection

Copy link
Collaborator

@TimothyZhang7 TimothyZhang7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@TimothyZhang7 TimothyZhang7 merged commit 197f4f9 into aden-hive:main Jan 27, 2026
6 of 16 checks passed
jhalak999 pushed a commit to jhalak999/hive that referenced this pull request Feb 17, 2026
…rage-file-locks-leak

fix(memory): patch ConcurrentStorage leak (WeakValueDictionary)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ConcurrentStorage unbounded memory growth in file_locks dict

2 participants